package org.jeecg.modules.xxgx.fpgl.service.impl;

import cn.hutool.core.io.FastByteArrayOutputStream;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.MinioUtil;
import org.jeecg.modules.innerApi.common.requestDto.CommonParam;
import org.jeecg.modules.innerApi.common.requestDto.InvoiceParam;
import org.jeecg.modules.innerApi.common.requestDto.InvoiceQueryParam;
import org.jeecg.modules.innerApi.common.requestDto.QdbsxzParam;
import org.jeecg.modules.innerApi.common.responseDto.FileStreamRtn;
import org.jeecg.modules.innerApi.common.responseDto.InvoiceQueryRtn;
import org.jeecg.modules.innerApi.common.responseDto.InvoiceRtn;
import org.jeecg.modules.innerApi.zhiYunApi.service.IZhiyunSkfpService;
import org.jeecg.modules.innerApi.zhiYunSdApi.responseVo.SdHqbswjcc15Rtn;
import org.jeecg.modules.innerApi.zhiYunSdApi.service.IZhiyunSdfpService;
import org.jeecg.modules.xxgx.common.enums.FplxdmEnum;
import org.jeecg.modules.xxgx.common.enums.FpztEnum;
import org.jeecg.modules.xxgx.common.enums.KplxEnum;
import org.jeecg.modules.xxgx.common.enums.TdyslxDmEnum;
import org.jeecg.modules.xxgx.djgl.entity.CsXxFpxxCezs;
import org.jeecg.modules.xxgx.djgl.entity.cezs.Cezs;
import org.jeecg.modules.xxgx.djgl.enums.ZsfsEnum;
import org.jeecg.modules.xxgx.djgl.service.ICsXxFpxxCezsService;
import org.jeecg.modules.xxgx.fpgl.entity.CsXxFpxx;
import org.jeecg.modules.xxgx.fpgl.entity.CsXxFpxxExt;
import org.jeecg.modules.xxgx.fpgl.entity.CsXxFpxxmx;
import org.jeecg.modules.xxgx.fpgl.mapper.CsXxFpxxMapper;
import org.jeecg.modules.xxgx.fpgl.mapper.CsXxFpxxmxMapper;
import org.jeecg.modules.xxgx.fpgl.service.ICsXxFpxxExtService;
import org.jeecg.modules.xxgx.fpgl.service.ICsXxFpxxService;
import org.jeecg.modules.xxgx.fpgl.service.ICsXxFpxxmxService;
import org.jeecg.modules.xxgx.fpgl.vo.CsXxFpjfVO;
import org.jeecg.modules.xxgx.fpgl.vo.EditDybzParam;
import org.jeecg.modules.xxgx.kpzdgl.service.ICsXxKpzdService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * @Description: 销项发票
 * @Author: jeecg-boot
 * @Date:   2023-09-21
 * @Version: V1.0
 */
@Service
public class CsXxFpxxServiceImpl extends ServiceImpl<CsXxFpxxMapper, CsXxFpxx> implements ICsXxFpxxService {

	@Autowired
	private CsXxFpxxMapper csXxFpxxMapper;
	@Autowired
	private CsXxFpxxmxMapper csXxFpxxmxMapper;
	@Autowired
	private ICsXxFpxxmxService fpxxmxService;

	@Autowired
	private ICsXxKpzdService kpzdService;

	@Autowired
	private IZhiyunSkfpService zhiyunSkfpService;
	@Autowired
	private IZhiyunSdfpService zhiyunSdfpService;

	@Autowired
	private ICsXxFpxxExtService csXxFpxxExtService;
	@Autowired
	private ICsXxFpxxCezsService csXxFpxxCezsService;

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void saveMain(CsXxFpxx csXxFpxx, List<CsXxFpxxmx> csXxFpxxmxList) {
		csXxFpxxMapper.insert(csXxFpxx);
		if(csXxFpxxmxList!=null && csXxFpxxmxList.size()>0) {
			for(CsXxFpxxmx entity:csXxFpxxmxList) {
				//外键设置
				entity.setFromid(csXxFpxx.getId());
				csXxFpxxmxMapper.insert(entity);
			}
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateMain(CsXxFpxx csXxFpxx,List<CsXxFpxxmx> csXxFpxxmxList) {
		csXxFpxxMapper.updateById(csXxFpxx);
		
		//1.先删除子表数据
		csXxFpxxmxMapper.deleteByMainId(csXxFpxx.getId());
		
		//2.子表数据重新插入
		if(csXxFpxxmxList!=null && csXxFpxxmxList.size()>0) {
			for(CsXxFpxxmx entity:csXxFpxxmxList) {
				//外键设置
				entity.setFromid(csXxFpxx.getId());
				csXxFpxxmxMapper.insert(entity);
			}
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		csXxFpxxmxMapper.deleteByMainId(id);
		csXxFpxxMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			csXxFpxxmxMapper.deleteByMainId(id.toString());
			csXxFpxxMapper.deleteById(id);
		}
	}
	/**
	 * 根据待开单据开具结果，将发票存储到发票信息表中
	 * @param dkfpParam 待开单据信息
	 * @param dkfpParam 待开发票信息
	 * @param fpxxRtn   开票返回信息
	 */
	@Transactional
	public String saveFpxxByDkdj(InvoiceParam dkfpParam, InvoiceRtn fpxxRtn){
		String companyId = dkfpParam.getQyxx().getId();
		int tenantId = dkfpParam.getKpzd().getTenantId();

		CsXxFpxx fpxx = new CsXxFpxx();
		fpxx.setId(IdWorker.get32UUID());
		fpxx.setDjbh(dkfpParam.getFpsqlsh());
		fpxx.setCompanyId(companyId);
		BeanUtils.copyProperties(dkfpParam, fpxx);
		fpxx.setSysOrgCode(dkfpParam.getBmdm());
		fpxx.setFpdm(fpxxRtn.getData().getFpdm());
		fpxx.setFphm(fpxxRtn.getData().getFphm());
		fpxx.setFplxmc(FplxdmEnum.getDescByValue(dkfpParam.getFplxdm()));
		fpxx.setKhdzdh(dkfpParam.getKhdzdh());
		fpxx.setKhyhzh(dkfpParam.getKhyhzh());
		fpxx.setXfdz(dkfpParam.getXfdz());
		fpxx.setXfdh(dkfpParam.getXfdh());
		fpxx.setXfyh(dkfpParam.getXfyh());
		fpxx.setXfzh(dkfpParam.getXfzh());

		fpxx.setDybz("0");
		fpxx.setCreateTime(new Date());

		String kplx = dkfpParam.getKplx();
		//负数发票开具
		if (!StringUtils.isEmpty(kplx) && kplx.equals(KplxEnum.FSFP.getValue())) {
			fpxx.setFpzt(FpztEnum.hc.getValue());//设置为红冲状态
		} else {
			fpxx.setFpzt(FpztEnum.zc.getValue());//设置为正常状态
		}
		fpxx.setXfmc(dkfpParam.getXfmc());
		fpxx.setXfdzdh(dkfpParam.getXfdzdh());
		fpxx.setXfsh(dkfpParam.getXfsh());
		fpxx.setXfyhzh(dkfpParam.getXfyhzh());
		fpxx.setEwm(fpxxRtn.getData().getEwm());
		fpxx.setSkm(fpxxRtn.getData().getSkm());
		fpxx.setJym(fpxxRtn.getData().getJym());
		fpxx.setKprq(fpxxRtn.getData().getKprq());
		fpxx.setTenantId(tenantId);
		save(fpxx);
		final String formId = fpxx.getId();
		List djmxs = dkfpParam.getFpmxs();
		List fpmxs = new ArrayList();

		djmxs.forEach(djmx -> {
			CsXxFpxxmx fpxxmx = new CsXxFpxxmx();
			BeanUtils.copyProperties(djmx, fpxxmx);
			fpxxmx.setId(IdWorker.getIdStr());
			fpxxmx.setCompanyId(companyId);
			fpxxmx.setFromid(formId);
			fpxxmx.setTenantId(tenantId);
			fpxxmx.setDjbh(fpxx.getDjbh());
			fpmxs.add(fpxxmx);
		});
		fpxxmxService.saveBatch(fpmxs);

		//保存扩展表信息(特定业务)
		CsXxFpxxExt csXxFpxxExt = new CsXxFpxxExt();
		csXxFpxxExt.setId(formId);
		csXxFpxxExt.setTenantId(tenantId);
		csXxFpxxExt.setFromid(formId);
		csXxFpxxExt.setCompanyId(dkfpParam.getKpzd().getCompanyId());
		if(TdyslxDmEnum.JZFW.getValue().equals(dkfpParam.getTdyslxdm())){
			csXxFpxxExt.setTdywInfo(JSON.toJSONString(dkfpParam.getTdywJzfw()));
		} else if(TdyslxDmEnum.HWYSFW.getValue().equals(dkfpParam.getTdyslxdm())){
			csXxFpxxExt.setTdywInfo(JSON.toJSONString(dkfpParam.getTdywHwysfwList()));
		} else if(TdyslxDmEnum.BDCXS.getValue().equals(dkfpParam.getTdyslxdm())){
			csXxFpxxExt.setTdywInfo(JSON.toJSONString(dkfpParam.getTdywBdcxs()));
		} else if(TdyslxDmEnum.BDCJYZLFW.getValue().equals(dkfpParam.getTdyslxdm())){
			csXxFpxxExt.setTdywInfo(JSON.toJSONString(dkfpParam.getTdywBdcjyzlfw()));
		} else if(TdyslxDmEnum.LKYSFW.getValue().equals(dkfpParam.getTdyslxdm())){
			csXxFpxxExt.setTdywInfo(JSON.toJSONString(dkfpParam.getTdywLkysfwList()));
		}
		//附加要素保存
		if(dkfpParam.getFjysList() != null && dkfpParam.getFjysList().size()>0){
			csXxFpxxExt.setFjysInfo(JSON.toJSONString(dkfpParam.getFjysList()));
		}
		if(!StringUtils.isEmpty(csXxFpxxExt.getTdywInfo()) || !StringUtils.isEmpty(csXxFpxxExt.getFjysInfo())){
			csXxFpxxExtService.saveOrUpdate(csXxFpxxExt);
		}

		//差额征收信息保存
		if(!ZsfsEnum.PTZS.getValue().equals(dkfpParam.getZsfs())) {
			//取差额信息
			List<CsXxFpxxCezs> csXxFpxxCezsList = new ArrayList<>();
			List<Cezs> cezsList = dkfpParam.getCezsList();
			cezsList.forEach(cezs -> {
				CsXxFpxxCezs csXxFpxxCezs = new CsXxFpxxCezs();
				BeanUtils.copyProperties(cezs, csXxFpxxCezs);
				csXxFpxxCezs.setId(IdWorker.getIdStr());
				csXxFpxxCezs.setFromid(formId);
				csXxFpxxCezs.setCompanyId(fpxx.getCompanyId());
				csXxFpxxCezs.setTenantId(String.valueOf(tenantId));
				csXxFpxxCezsList.add(csXxFpxxCezs);
			});
			csXxFpxxCezsService.saveBatch(csXxFpxxCezsList);
		}

		return formId;
	}

	/**
	 * 修改打印标志
	 * @param editDybzParam
	 */
	@Transactional
	@Override
	public Result updateDybz(EditDybzParam editDybzParam) {
		List<CsXxFpxx> list = new ArrayList<>();
		editDybzParam.getIds().forEach(id -> {
			CsXxFpxx csXxFpxx = new CsXxFpxx();
			csXxFpxx.setId(id);
			csXxFpxx.setDybz(editDybzParam.getDybz());
			list.add(csXxFpxx);
		});
		this.updateBatchById(list);

		return Result.OK("修改成功");
	}

	/**
	 * 发票下载
	 * @param fpid
	 * @param downflag 1:ofd  2:pdf 3:xml
	 * @return
	 */
	@Override
	public FileStreamRtn<CsXxFpxx> download(String fpid, String downflag) throws IOException {
		CsXxFpxx csXxFpxxEntity = this.getById(fpid);
		if(csXxFpxxEntity==null) {
			throw new JeecgBootException("未找到对应数据");
		}
		FileStreamRtn fileStreamRtn = null;
		try {
			//数据库中url地址已存在，则从minio中下载
			String existFileUrl = "";
			if ("1".equals(downflag) && !StringUtils.isEmpty(csXxFpxxEntity.getOfddz())) {
				existFileUrl = csXxFpxxEntity.getOfddz();
			} else if ("2".equals(downflag) && !StringUtils.isEmpty(csXxFpxxEntity.getPdfdz())) {
				existFileUrl = csXxFpxxEntity.getPdfdz();
			} else if ("3".equals(downflag) && !StringUtils.isEmpty(csXxFpxxEntity.getXmldz())) {
				existFileUrl = csXxFpxxEntity.getXmldz();
			}

			if (!StringUtils.isEmpty(existFileUrl)) {
				if (existFileUrl.toLowerCase().startsWith("http")) {
					//http开头直接下载
					FastByteArrayOutputStream outputStream = new FastByteArrayOutputStream();
					HttpUtil.download(existFileUrl, outputStream, true);

					fileStreamRtn = new FileStreamRtn();
					fileStreamRtn.setFileStream(new ByteArrayInputStream(outputStream.toByteArray()));
					return fileStreamRtn;
				} else {
					//非http开头从minio下载
					InputStream inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), existFileUrl);
					if (inputStream != null) {
						ByteArrayOutputStream baos = new ByteArrayOutputStream();
						byte[] buffer = new byte[1024];
						int len;
						while ((len = inputStream.read(buffer)) != -1) {
							baos.write(buffer, 0, len);
						}
						baos.flush();

						fileStreamRtn = new FileStreamRtn();
						fileStreamRtn.setFileStream(new ByteArrayInputStream(baos.toByteArray()));
						return fileStreamRtn;
					}
				}
			}

			String fplxdm = csXxFpxxEntity.getFplxdm();
			String msg = "";
			if (FplxdmEnum.dzpp.getValue().equals(fplxdm)) {
				//电子普票下载
				//取终端信息
				CommonParam commonParam = kpzdService.getCommonParamByKpzd(csXxFpxxEntity.getKpzddm());

				if ("2".equals(downflag)) {//pdf
					InvoiceQueryParam invoiceQueryParam = new InvoiceQueryParam();
					invoiceQueryParam.setKpzd(commonParam.getKpzd());
					invoiceQueryParam.setQyxx(commonParam.getQyxx());
					invoiceQueryParam.setFwqxx(commonParam.getFwqxx());

					invoiceQueryParam.setFplxdm(csXxFpxxEntity.getFplxdm());
					invoiceQueryParam.setFpdm(csXxFpxxEntity.getFpdm());
					invoiceQueryParam.setFphm(csXxFpxxEntity.getFphm());
					invoiceQueryParam.setKprqq(csXxFpxxEntity.getKprq());
					invoiceQueryParam.setKprqz(csXxFpxxEntity.getKprq());
					InvoiceQueryRtn invoiceQueryRtn = zhiyunSkfpService.invoiceQuery(invoiceQueryParam);
					List<String> ids = new ArrayList<>();
					invoiceQueryRtn.getData().forEach(rtnData -> {
						ids.add(rtnData.getId());
					});

					if (ids.size() == 0) {
						throw new JeecgBootException("未查询到发票信息");
					}

					fileStreamRtn = zhiyunSkfpService.downloadPdf(fplxdm, ids);
				} else if ("1".equals(downflag)) {//ofd
					fileStreamRtn = zhiyunSkfpService.downloadOfd(csXxFpxxEntity.getFpdm(), csXxFpxxEntity.getFphm(), commonParam.getFwqxx().getJqbh());
				}
			} else if (FplxdmEnum.dzzp.getValue().equals(fplxdm)) {
				//电子专票下载
				fileStreamRtn = zhiyunSkfpService.zpDownload(csXxFpxxEntity.getFpdm(), csXxFpxxEntity.getFphm(), downflag);
			} else if (FplxdmEnum.sdzp.getValue().equals(fplxdm) || FplxdmEnum.sdpp.getValue().equals(fplxdm)) {
				//全电版式下载
				//取终端信息
				CommonParam commonParam = kpzdService.getCommonParamByKpzd(csXxFpxxEntity.getKpzddm());

				QdbsxzParam param = new QdbsxzParam();
				param.setKpzd(commonParam.getKpzd());
				param.setQyxx(commonParam.getQyxx());
				param.setFwqxx(commonParam.getFwqxx());

				param.setNsrsbh(csXxFpxxEntity.getXfsh());
				param.setFphm(csXxFpxxEntity.getFphm());
				param.setDownflag("4");
				param.setAddSeal("1");
				SdHqbswjcc15Rtn sdHqbswjcc15Rtn = zhiyunSdfpService.getInvoicePdfOfd(param);
				if (sdHqbswjcc15Rtn.getSuccess()) {
					String url = "";
					if ("1".equals(downflag)) {
						url = sdHqbswjcc15Rtn.getOfdUrl();
					} else if ("2".equals(downflag)) {
						url = sdHqbswjcc15Rtn.getPdfUrl();
					} else if ("3".equals(downflag)) {
						url = sdHqbswjcc15Rtn.getXmlUrl();
					}
					FastByteArrayOutputStream outputStream = new FastByteArrayOutputStream();
					HttpUtil.download(url, outputStream, true);

					fileStreamRtn = new FileStreamRtn();
					fileStreamRtn.setFileStream(new ByteArrayInputStream(outputStream.toByteArray()));

					//全电更新数据库，不保存到minio
					CsXxFpxx updateFpxx = new CsXxFpxx();
					updateFpxx.setId(csXxFpxxEntity.getId());
					updateFpxx.setPdfdz(sdHqbswjcc15Rtn.getPdfUrl());
					updateFpxx.setOfddz(sdHqbswjcc15Rtn.getOfdUrl());
					updateFpxx.setXmldz(sdHqbswjcc15Rtn.getXmlUrl());

					csXxFpxxEntity.setPdfdz(sdHqbswjcc15Rtn.getPdfUrl());
					csXxFpxxEntity.setOfddz(sdHqbswjcc15Rtn.getOfdUrl());
					csXxFpxxEntity.setXmldz(sdHqbswjcc15Rtn.getXmlUrl());

					this.updateById(updateFpxx);
					return fileStreamRtn;
				} else {
					throw new JeecgBootException(sdHqbswjcc15Rtn.getMsg());
				}
			} else {
				throw new JeecgBootException("该发票类型不支持下载");
			}

			if (fileStreamRtn == null) {
				throw new JeecgBootException("下载失败");
			}

			//解决inputstream流不能重复读取的问题
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			byte[] buffer = new byte[1024];
			int len;
			InputStream in = fileStreamRtn.getFileStream();
			while ((len = in.read(buffer)) != -1) {
				baos.write(buffer, 0, len);
			}
			baos.flush();

			ByteArrayInputStream forUpload = new ByteArrayInputStream(baos.toByteArray());
			ByteArrayInputStream forReturn = new ByteArrayInputStream(baos.toByteArray());
			fileStreamRtn.setFileStream(forReturn);

			//保存到minio
			try {
				String fileExt = "";
				if ("1".equals(downflag)) {
					fileExt = ".ofd";
				} else if ("2".equals(downflag)) {
					fileExt = ".pdf";
				} else if ("3".equals(downflag)) {
					fileExt = ".xml";
				}
				String relativePath = csXxFpxxEntity.getXfsh() + "/" + csXxFpxxEntity.getFplxdm() + "/" + DateUtils.formatDate(csXxFpxxEntity.getKprq(), "yyyyMM") + "/" + csXxFpxxEntity.getFphm() + fileExt;
				String fileUrl = MinioUtil.upload(forUpload, relativePath);

				CsXxFpxx updateFpxx = new CsXxFpxx();
				updateFpxx.setId(csXxFpxxEntity.getId());
				if ("1".equals(downflag)) {
					updateFpxx.setOfddz(relativePath);
					csXxFpxxEntity.setOfddz(relativePath);
				} else if ("2".equals(downflag)) {
					updateFpxx.setPdfdz(relativePath);
					csXxFpxxEntity.setPdfdz(relativePath);
				} else if ("3".equals(downflag)) {
					updateFpxx.setXmldz(relativePath);
					csXxFpxxEntity.setXmldz(relativePath);
				}
				this.updateById(updateFpxx);
			} catch (Exception e) {
				log.error(e.getMessage(), e);
			}

			return fileStreamRtn;
		}finally {
			if(fileStreamRtn != null){
				fileStreamRtn.setData(csXxFpxxEntity);
			}
		}
	}

	@Override
	public Result<CsXxFpjfVO> getBswj(String fpxxId) {
		CsXxFpxx csXxFpxx = this.getById(fpxxId);
		if (csXxFpxx == null) {
			return Result.error("未找到对应数据");
		}
		TenantContext.setTenant(String.valueOf(csXxFpxx.getTenantId()));
		String fplxdm = csXxFpxx.getFplxdm();
		if(!FplxdmEnum.sdzp.getValue().equals(fplxdm)
				&& !FplxdmEnum.sdpp.getValue().equals(fplxdm)
				&& !FplxdmEnum.dzpp.getValue().equals(fplxdm)
				&& !FplxdmEnum.dzzp.getValue().equals(fplxdm)
		){
			return Result.error("非电子票");
		}

		try {
			if (StringUtils.isEmpty(csXxFpxx.getOfddz())) {
				FileStreamRtn<CsXxFpxx> fileStreamRtn = this.download(csXxFpxx.getId(), "1");
				if(fileStreamRtn != null && fileStreamRtn.getData() != null){
					csXxFpxx = fileStreamRtn.getData();
				}
			}
			if (StringUtils.isEmpty(csXxFpxx.getPdfdz())) {
				FileStreamRtn<CsXxFpxx> fileStreamRtn = this.download(csXxFpxx.getId(), "2");
				if(fileStreamRtn != null && fileStreamRtn.getData() != null){
					csXxFpxx = fileStreamRtn.getData();
				}
			}
			if (FplxdmEnum.sdzp.getValue().equals(fplxdm) || FplxdmEnum.sdpp.getValue().equals(fplxdm)) {
				if (StringUtils.isEmpty(csXxFpxx.getXmldz())) {
					FileStreamRtn<CsXxFpxx> fileStreamRtn = this.download(csXxFpxx.getId(), "3");
					if(fileStreamRtn != null && fileStreamRtn.getData() != null) {
						csXxFpxx = fileStreamRtn.getData();
					}
				}
			}
		}catch (Exception e){
			log.error(e.getMessage(),e);
		}

		//获取minio前端访问地址
		if (StringUtils.isNotEmpty(csXxFpxx.getPdfdz()) && !csXxFpxx.getPdfdz().toLowerCase().startsWith("http")) {
			String fullUrl = MinioUtil.getObjectUrl(MinioUtil.getBucketName(), csXxFpxx.getPdfdz(), 7);
			csXxFpxx.setPdfdz(fullUrl);
		}
		if (StringUtils.isNotEmpty(csXxFpxx.getOfddz()) && !csXxFpxx.getOfddz().toLowerCase().startsWith("http")) {
			String fullUrl = MinioUtil.getObjectUrl(MinioUtil.getBucketName(), csXxFpxx.getOfddz(), 7);
			csXxFpxx.setOfddz(fullUrl);
		}
		if(FplxdmEnum.sdzp.getValue().equals(fplxdm) || FplxdmEnum.sdpp.getValue().equals(fplxdm)) {
			if (org.parboiled.common.StringUtils.isNotEmpty(csXxFpxx.getXmldz()) && !csXxFpxx.getXmldz().toLowerCase().startsWith("http")) {
				String fullUrl = MinioUtil.getObjectUrl(MinioUtil.getBucketName(), csXxFpxx.getXmldz(), 7);
				csXxFpxx.setXmldz(fullUrl);
			}
		}

		CsXxFpjfVO csXxFpjfVO = new CsXxFpjfVO();
		BeanUtils.copyProperties(csXxFpxx, csXxFpjfVO);

		return Result.OK(csXxFpjfVO);
	}

}
